define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'moneylog/index' + location.search,
                    table: 'moneylog',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('用户id')},
                        {field: 'money', title: __('变更金额')},
                        {field: 'bgexplain', title: __('变更原因'), 
                            searchList: {
                                "sign_jl":"签到下发奖励",
                                "dikou":"抵扣使用",
                                "recycle":"商品回收",
                                "shop":"兑换商城商品",
                                "pidback":"好友首购返利",
                                "yqjl":"邀请奖励",
                                "kami":"礼包码兑换",
                                "xscz":"星石充值"
                            }, 
                            formatter: Table.api.formatter.label
                        },
                        {field: 'aftermoney', title: __('变更后余额')},
                        {field: 'addtime', title: __('变更时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
